<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>中国福利彩票</title>
<link href="css/style.css" type="text/css" rel="stylesheet" />
	<link rel="icon" href="images/favicon.png" type="image/x-icon"/>
<script src="js/jquery-1.7.2.min.js"></script>
</head>

<body>
	<div class="Header">
    	<div class="width1200">
        	<div class="left H_logo"><img src="images/logo.png" width="200" /></div>
            <div class="right H_right">  <a href="Login.html">登录</a> </div>
            <div class="clear"></div>
        </div>
    </div>
	
    <div class="width1200">
    	<div class="Register">
        	
            <div class="REG_stpe"><img src="images/Zimg1.png" width="503" /></div>
            
            <div class="REG_Sone">
            	<table width="100%" border="0" cellspacing="15" cellpadding="0">
                  <tr style="display: none;">
                    <td width="20%" align="right">国籍/地区</td>
                    <td width="80%">
                    	<select name="" class="RE_St">
                    		<option value="中国大陆">中国大陆</option>
                    	</select>
                    </td>
                  </tr>
                  <tr>
                    <td align="right">手机号</td>
                    <td>
                    	<div class="REP_b">
                        	<select name="" class="RE_St1 left">
                        		<option value="86">86</option>
                        	</select>
                            <input type="text" placeholder="请输入你得手机号码" class="REP_n left" id="phoneNum" maxlength="11"/>
                            <div class="clear"></div>
                        </div>
                    </td>
                  </tr>
                  <tr>
                    <td align="right">短信验证码</td>
                    <td>
                    	<div class="REP_duan">
                        	<input type="text" placeholder="验证码是6-8位数" class="REP_y" id="smsCode" maxlength="8"/>
                            <input type="button" id="smsCodeBtn" value="获取验证码" class="REP_g" onclick="getVerificationCode()" />
                            <div class="clear"></div>
                        </div>
                    </td>
                  </tr>
                  <tr>
                    <td align="right">密码</td>
                    <td>
                    	<div class="REP_duan">
                        	<input type="password" placeholder="请输入密码" class="REP_y" id="password"  />
                            
                            <div class="clear"></div>
                        </div>
                    </td>
                  </tr>
                  <tr>
                    <td align="right">&nbsp;</td>
                    <td> 
                    	<div class="RS_yuedu">
                        	<input name="agreement" type="checkbox" value="" checked="checked" class="RS_box" id="agreement"/>阅读<a href="javascript:void(0);" class="cd-popup-trigger0">《会员服务条例》</a>
                        </div>
                    </td>
                  </tr>
                  <tr>
                    <td align="right">&nbsp;</td>
                    <td>
                    	<input type="submit" value="下一步" class="RS_go" onclick="nextStep()" />
                    </td>
                  </tr>
                </table>
            </div>
            
        </div>
    </div>
    
    <div class="Footer">
    	<div class="width1200">
        	<div class="left">版权所有：中国福利彩票发行管理中心    网站主办：中国福利彩票发行管理中心</div>
            <div class="right"><img src="images/Flogo.png" width="110" /></div>
            <div class="clear"></div>
        </div>
    </div>
    
    
    <!--弹框-->
    <div class="cd-popup">
        <div class="cd-popup-container">
            <div class="TC_title">
            	<a href="#0" class="cd-popup-close right"></a>
            	会员服务条例
            </div>
            
            <div class="TC_cont">
            	<div class="TC_n">
                	<div class="TC_t">会员服务条例</div>
                    一、支付宝服务协议的确认<br />
                    二、支付宝服务相关定义<br />
                    三、支付宝为您提供的服务内容<br />
                    四、支付宝会员号和账户的注册、使用和注销<br />
                    五、使用支付宝服务的注意事项<br />
                    六、用户合法使用支付宝服务的承诺<br />
                    七、权益保障及隐私保护<br />
                    八、不可抗力、免责及责任限制<br />
                    九、完整协议
                </div>
                <input type="button" class="TC_but" value="已阅读并同意此条例" />
            </div>
        </div>
    </div>
    
</body>

<!--弹出-->
<script type="text/javascript">
var channelId="";
    /*弹框JS内容*/
    jQuery(document).ready(function($){
    	channelId = getCookie("channelId");
    	
        //打开窗口
        $('.cd-popup-trigger0').on('click', function(event){
            event.preventDefault();
            $('.cd-popup').addClass('is-visible');
            //$(".dialog-addquxiao").hide()
        });
        //关闭窗口
        $('.cd-popup').on('click', function(event){
            if( $(event.target).is('.cd-popup-close') || $(event.target).is('.cd-popup') ) {
                event.preventDefault();
                $(this).removeClass('is-visible');
            }
        });
        //ESC关闭
        $(document).keyup(function(event){
            if(event.which=='27'){
                $('.cd-popup').removeClass('is-visible');
            }
        });
		
    });
    
    
   //获得“短信验证码”
    function getVerificationCode() {
	   //验证手机号格式
    	if(!validatePhoneNum('phoneNum')){
    		return;
    	}
	  var para = {
			  mobile:$('#phoneNum').val(),
			  type:1
	        };
	$.ajax({
		url : "../../api/CrmSystem/verification/msgcode",
		async:false,
		type : "POST",
		herder:{
			'Accept':'application/json',
			'Content-Type':'application/json'
		},
		dataType:"json",
		contentType:"application/json",
		data:JSON.stringify(para),
		error:function(XMLHttpRequest, textStatus, errorThrown){
			alert(errorThrown);
		},
		success: function(data, textStatus){
			if(data.success==true){
				messageCodeTime('smsCodeBtn');
			}else{
				alert("error:"+data.description);
			}
		}		
	});
}   
   
      //点击“下一步”执行  
function nextStep() {
	 //验证是否勾选协议
	if(!validateAgreement('agreement')){
		return;
	}
	 //验证手机号格式
	if(!validatePhoneNum('phoneNum')){
		return;
	}
	 //验证手机验证码格式
	if(!validatesmsCode('smsCode')){
		return;
	}
	//验证密码
	if(!validateRegistePwd('password')){
		return;
	}
	
  var para = {
		  	mobile:$('#phoneNum').val(),
			password:sha256_digest($('#password').val()),
			smsCode:$('#smsCode').val(),
			channelId:channelId
        };
	
	$.ajax({
		url : "../../api/CrmSystem/register",
		async:false,
		type : "POST",
		herder:{
			'Accept':'application/json',
			'Content-Type':'application/json'
		},
		dataType:"json",
		contentType:"application/json",
		data: JSON.stringify(para),
		error:function(XMLHttpRequest, textStatus, errorThrown){
			alert(errorThrown);
		},
		success: function(data, textStatus){
			if(data.success == true){
				login();
			}else{
				alert("error:"+data.description);
				return;
			}
		}		
	});
}   

      //注册成功调用login登录获得accountId和token
      function login(){
    	  var para = {
    			  	id:$('#phoneNum').val(),
    				password:sha256_digest($('#password').val())
//     				channelId:channelId
    	        };
    		
    		$.ajax({
    			url : "../../api/CrmSystem/login",
    			async:false,
    			type : "POST",
    			herder:{
    				'Accept':'application/json',
    				'Content-Type':'application/json'
    			},
    			dataType:"json",
    			contentType:"application/json",
    			data: JSON.stringify(para),
    			error:function(XMLHttpRequest, textStatus, errorThrown){
    				alert(errorThrown);
    			},
    			success: function(data, textStatus){
    				if(data.success == true){
    					if(data.status=="1000"){
    						setCookie('accountId',data.accountId,0);
    						setCookie('token',data.token,0);
    						window.location.href='Register1.html?password='+sha256_digest($('#password').val())+'';
    					}
    				}else{
    					alert("error:"+data.description);
    					return;
    				}
    			}		
    		});
      }
</script>
<script src="js/SHA256.js"></script>
<script src="js/jsCallCookies.js"></script>
<script src="js/validation.js"></script>
<script src="js/countDown.js"></script>
</html>
